
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include "Probability.h"

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Probability)
{
    TEST(should be able to check wrong input probability)
    {
        int flag = 0;
        try
        {
            Probability prob(-0.2);
        }
        catch (int exception)
        {
            flag = 1;
            ASSERT_EQ(OUT_OF_RANGE_OF_PROBABILITY, exception);
        }
        ASSERT_EQ(1, flag);
        try
        {
            Probability prob(1.01);
        }
        catch (int exception)
        {
            flag = 2;
            ASSERT_EQ(OUT_OF_RANGE_OF_PROBABILITY, exception);
        }
        ASSERT_EQ(2, flag);
    }

    TEST(should be able to get probability of both events)
    {
        Probability prob1(0.4), prob2(0.3);
        ASSERT_EQ(Probability(0.12), prob1 & prob2);
    }

    TEST(should be able to get probability of single event)
    {
        Probability prob1(0.4), prob2(0.3);
        ASSERT_EQ(Probability(0.58), prob1 | prob2);
    }

    TEST(should be able to get probability of no a given event)
    {
        Probability prob(0.4);
        ASSERT_EQ(Probability(0.6), !prob);
    }
};

